package com.hup.minicontroller.client.model;

import android.bluetooth.BluetoothDevice;

import java.util.ArrayList;
import java.util.Collection;

import lombok.Data;

/**
 * 扫描到的[可以连接]的服务端
 *
 * @author hugan
 * @date 2021/5/19
 */
@Data
public class ScannedServerItem {

    private boolean isLan;
    private LanBroadcastServer lanBroadcastServer;
    private BluetoothDevice bluetoothDevice;

    public static ArrayList<ScannedServerItem> cast(Collection<LanBroadcastServer> broadcastServers) {
        ArrayList<ScannedServerItem> res = new ArrayList<>(broadcastServers.size());
        for (LanBroadcastServer broadcastServer : broadcastServers) {
            ScannedServerItem item = new ScannedServerItem();
            item.isLan = true;
            item.lanBroadcastServer = broadcastServer;
            res.add(item);
        }
        return res;
    }

    public static ArrayList<ScannedServerItem> cast2(Collection<BluetoothDevice> bluetoothDevices) {
        ArrayList<ScannedServerItem> res = new ArrayList<>(bluetoothDevices.size());
        for (BluetoothDevice bluetoothDevice : bluetoothDevices) {
            ScannedServerItem item = new ScannedServerItem();
            item.isLan = false;
            item.bluetoothDevice = bluetoothDevice;
            res.add(item);
        }
        return res;
    }
}
